<!-- 部门选择下拉框 -->
<template>
  <el-select clearable v-model="model" placeholder="请选择用户" style="width: 100%;" filterable :value-key="'userId'">
    <el-option :value="item.userId" :label="item.userName" :key="item.userId" v-for="item in data" />
  </el-select>
</template>

<script setup>
import { ref } from 'vue';
import { EleMessage, toTree } from 'ele-admin-plus';
import { pageUsers } from '@/api/system/user/index';

defineProps({
  /** 提示信息 */
  placeholder: {
    type: String,
    default: '请选择归属部门'
  }
});

/** 选中的部门 */
const model = defineModel({ type: [Number, String] });

/** 部门数据 */
const data = ref([]);

/** 获取部门数据 */
pageUsers()
  .then((list) => {
    data.value = list.rows || []
  })
  .catch((e) => {
    EleMessage.error({ message: e.message, plain: true });
  });
</script>
